﻿using System.Windows;
using System.Windows.Controls;
using Microsoft.Win32;
using MIM.CMS.CMSClient.Common;

namespace MIM.CMS.CMSClient.CmsUserControl
{
    /// <summary>
    /// Interaction logic for PhotoUpload.xaml
    /// </summary>
    public partial class PhotoUpload : UserControl
    {
        public PhotoUpload()
        {
            InitializeComponent();
        }

        private void btnBrowse_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();
            dialog.Filter = "JPEG files|*.jpg|png files|*.png";
            if(dialog.ShowDialog().Value)
            {
                txtPhotoPath.Text = dialog.FileName;
            }

        }

        public byte[] ImageData { get; set; }
        public string FilePath
        {
            get
            {
                return txtPhotoPath.Text;
            }
        }
        public Visibility IsSeeVisible
        {
            set
            {
                btnSee.Visibility = value;
            }
        }

        private void btnSee_Click(object sender, RoutedEventArgs e)
        {
            img.Source = ImageHelper.GetImage(ImageData);
            ImageViewer.IsOpen = true;
        }
    }
}
